﻿Imports Microsoft.Build.Framework
Imports Microsoft.Build.Utilities
Imports System
Imports System.IO

Namespace System.Workflow.ComponentModel.Compiler
    Public NotInheritable Class CompileWorkflowCleanupTask
        Inherits Task
        Implements ITask
        ' Methods
        Public Sub New()
            MyBase.New(New ResourceManager("System.Workflow.ComponentModel.BuildTasksStrings", Assembly.GetExecutingAssembly))
        End Sub

        Public Overrides Function Execute() As Boolean
            If (Not Me.temporaryFiles Is Nothing) Then
                Dim item As ITaskItem
                For Each item In Me.temporaryFiles
                    Dim itemSpec As String = item.ItemSpec
                    If File.Exists(itemSpec) Then
                        File.Open(itemSpec, FileMode.Truncate).Close
                    End If
                Next
            End If
            Return True
        End Function


        ' Properties
        Public Property TemporaryFiles As ITaskItem()
            Get
                Return Me.temporaryFiles
            End Get
            Set(ByVal value As ITaskItem())
                Me.temporaryFiles = value
            End Set
        End Property


        ' Fields
        Private temporaryFiles As ITaskItem()
    End Class
End Namespace

